package network;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;


public class MyTcpEchoServer extends TcpEchoServer{
    //创建一个哈希表
    Map<String,String> map = new HashMap<>();
    public MyTcpEchoServer(int port) throws IOException {
        super(port);
        map.put("hello","你好");
        map.put("money","金钱");
        map.put("cat","小猫");
        map.put("apple","苹果");
        map.put("english","英语");
    }

    @Override
    public String process(String request) {
        return map.getOrDefault(request,"没有查到该单词") + "\n";
    }

    public static void main(String[] args) throws IOException {
        MyTcpEchoServer myServer = new MyTcpEchoServer(9090);
        myServer.start();
    }
}
